<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="author" content="lushu">
		<title>销售数据对帐</title>
		<script type="text/javascript" src="../script/common.js" language="JavaScript"></script>
		<script type="text/javascript" language="JavaScript">
			var Page;					//数据表格对象
			
			function load() {
				Eui.showNavigation();
				Page = {};
				Page.DEFAULT_DAY = 1;			//默认是显示昨天的
				Page.OrgLevel = {org:Constants.ORG_LEVEL_STATION};
				Page.PresetOrg = {org:true};
				Page.form = $('searchForm');
				Clear.List.initOrganizations();
				Common.initDict(Page.form.status, "result_status", "全   部");
				Eui.initDateInput("businessDateTd","业务日期",Page.form.name,"businessDate","_pastDate");
				Page.form.businessDate.value = TX.Misc.getDateBefore(Page.DEFAULT_DAY); 
 				createTable();
				setPages(["listView","detailView"]);
			}
			
			function createTable() {
 				var columns = [];
 				columns[8] = {title:"操作",width:"10%",order:false,align:"left",
					render:function(v,r){
						var s = "<a href=# onclick=\""
								+ "Clear.MatchResult.showDetail('"+r[0]+"');\">明细<\/a>";
						if (checkable(r))
							s += " <a href=# onclick=\"recreateFile('"+r[7]+"','"+r[2]+"','"+r[1]+"')\">重新对帐<\/a>";
						return s;
					}};
 				Page.qt = new QueryTable("match_result_list", Page.form, "datalist", columns);
			}
			
			function checkable(r){
				return r[8]==MatchResultStatus.EPS_OK;
			}
			function recreateFile(id,date,orgName){
				if(showQuestion('确认要重新生成['+orgName+']在['+date+']对帐文件吗?')){
					DWR.call('matchResultService.reCreateFile',id,date,function(v){
						showInformation("对帐文件生成成功");
						Page.qt.showTable();
					});
				}
			}
		</script>
	</head>
	<body onload="load()">
		<div class="nav"><div id="nav">&nbsp;</div></div>
	
		<div id="listView">
			<div class="searchForm">
				<form id="searchForm" name="searchForm">
					<table cellSpacing="0" cellPadding="4" width="100%" border="0">
						<tr>
							<td class="label4" id="org"></td>
							<td class="label4" id="businessDateTd"></td>
							<td>
								<label>对帐结果</label>
								<select name="status"><option></option></select>
							</td>
							<td><button onclick="Page.qt.showTable();">查 询</button></td>
						</tr>
					</table>
				</form>
			</div>
			<div id="datalist"></div>
		</div>
		
		<div id="detailView" style="display:none;">
			<form id="viewForm" name="viewForm" class="label5 viewTable">
				<div class="form">
					<div class="formTitle">对帐明细</div>
					<div id="matchResultDetail"></div>
				</div>
				<p><button onclick="switchPage('listView');">返 回</button></p>
			</form>
		</div>
	</body>
</html>